package com.example.onlinemusicserver.service;

import com.example.onlinemusicserver.mapper.MusicMapper;
import com.example.onlinemusicserver.model.Music;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MusicService {
    @Autowired
    private MusicMapper musicMapper;

    public int insert(String title, String author, String uploadtime,String path,String imgpath, int userId){
        return musicMapper.insert(title,author,uploadtime,path,imgpath,userId);
    }

    public List<Music> selectByTitle(String title) {
        return musicMapper.selectByTitle(title);
    }

    public Music selectById(int musicId) {
        return musicMapper.selectById(musicId);
    }

    public int deleteById(int musicId) {
        return musicMapper.deleteById(musicId);
    }

    public List<Music> findMusic(int pageRange, int pageSize) {
        return musicMapper.findMusic(pageRange,pageSize);
    }

    public List<Music> findMusicByName(String name, int pageRange, int pageSize) {
        return musicMapper.findMusicByName(name,pageRange,pageSize);
    }

    public int totalMusic(String name) {
        return musicMapper.totalMusic(name);
    }
}
